<include file="Public:header" />
<bootstrapcss />
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
<!-- 导航栏结束 -->
<ul id="myTab" class="nav nav-tabs">
   <li class="active">
		 <a href="#home" data-toggle="tab">菜单列表</a>
   </li>
   <li>
		<a href="javascript:;" onclick="add()">添加菜单</a>
	</li>
</ul>
<form action="{:U('Admin/Nav/order')}" method="post">
	<div id="myTabContent" class="tab-content">
	   <div class="tab-pane fade in active" id="home">
			<table class="table table-striped table-bordered table-hover table-condensed">
				<tr>
					<th>菜单名</th>
					<th>连接</th>
					<th>操作</th>
				</tr>
				<foreach name="data" item="v">
					<tr>
						<td>{$v['_name']}</td>
						<td>{$v['url']}</td>
						<td>
							<a href="javascript:;" menuID="{$v['menuid']}" menuName="{$v['menuname']}"  onclick="add_child(this)">添加子菜单</a> |
							<a href="javascript:;" menuID="{$v['menuid']}" menuName="{$v['menuname']}" url="{$v['url']}" remark="{$v['remark']}" onclick="edit(this)">修改</a> |
							<a href="javascript:if(confirm('确定删除？'))location='{:U('Admin/Nav/delete',array('id'=>$v['menuid']))}'">删除</a>
						</td>
					</tr>
				</foreach>
			</table>
	   </div>
	</div>
</form>
<!-- 添加菜单模态框开始 -->
<div class="modal fade" id="bjy-add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		 <div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					添加菜单
				</h4>
			</div>
			<div class="modal-body">
				<form id="bjy-form" class="form-inline" action="{:U('Admin/Nav/add')}" method="post">
					<input type="hidden" name="fid" value="0">
					<table class="table table-striped table-bordered table-hover table-condensed">
						<tr>
							<th width="12%">菜单名：</th>
							<td>
								<input class="form-control" type="text" name="menuName">
							</td>
						</tr>
						<tr>
							<th>连接：</th>
							<td>
								<input class="form-control" type="text" name="url"> 输入模块/控制器/方法即可 例如 Admin/Nav/index
							</td>
						</tr>
						<tr>
							<th>备注</th>
							<td>
								<input class="form-control" type="text" name="remark">
							</td>
						</tr>
						<tr>
							<th></th>
							<td>
								<input class="btn btn-success" type="submit" value="添加">
							</td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</div>
</div>
<!-- 添加菜单模态框结束 -->

<!-- 修改菜单模态框开始 -->
<div class="modal fade" id="bjy-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		 <div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					修改菜单
				</h4>
			</div>
			<div class="modal-body">
				<form id="bjy-form" class="form-inline" action="{:U('Admin/Nav/edit')}" method="post">
					<input type="hidden" name="menuID">
					<table class="table table-striped table-bordered table-hover table-condensed">
						<tr>
							<th width="12%">菜单名：</th>
							<td>
								<input class="form-control" type="text" name="menuName">
							</td>
						</tr>
						<tr>
							<th>连接：</th>
							<td>
								<input class="form-control" type="text" name="url"> 输入模块/控制器/方法即可 例如 Admin/Nav/index
							</td>
						</tr>
						<tr>
							<th>备注</th>
							<td>
								<input class="form-control" type="text" name="remark">
							</td>
						</tr>
						<tr>
							<th></th>
							<td>
								<input class="btn btn-success" type="submit" value="修改">
							</td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</div>
</div>
</div>
<!-- 修改菜单模态框结束 -->
<bootstrapjs />
<include file="Public:footer" />
<script>
// 添加菜单
function add(){
	$("input[name='name'],input[name='mca']").val('');
	$("input[name='pid']").val(0);
	$('#bjy-add').modal('show');
}

// 添加子菜单
function add_child(obj){
	var navId=$(obj).attr('menuID');
	$("input[name='fid']").val(navId);
	$("input[name='menuName']").val('');
	$("input[name='url']").val('');
	$('#bjy-add').modal('show');
}

// 修改菜单
function edit(obj){
	var navId=$(obj).attr('menuID');
	var navName=$(obj).attr('menuName');
	var navMca=$(obj).attr('url');
	var navIco=$(obj).attr('remark');
	$("input[name='menuID']").val(navId);
	$("input[name='menuName']").val(navName);
	$("input[name='url']").val(navMca);
	$("input[name='remark']").val(navIco);
	$('#bjy-edit').modal('show');
}

</script>
</body>
</html>
